<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>order</title>
    <script src="./jquery.js"></script>
    <script>

        $(function(){
            function getUrlParam(name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
                var r = window.location.search.substr(1).match(reg);  //匹配目标参数
                if (r != null) return unescape(r[2]); return null; //返回参数值
            }
            let orderId = getUrlParam("id");

            $("#pay").click(function () {
                console.log(orderId)
                $.ajax({
                    type: "PUT",
                    url: "http://localhost:8080/order/edit/1",
                    data: JSON.stringify({
                        "price": "12.3",
                        "orderId": orderId
                    }) ,
                    contentType: "application/json;charset=utf-8",
                    success: function(msg){
                        window.location.href=`result.html?id=${orderId}`
                    }
                });

            })
        });

    </script>

</head>

<body>
<div>
    <button id="pay">支付</button>

</div>

</body>
</html>